<?php 
	class Main{

		private static $obj;
		private $db_connect;
		
		private function __construct (){
				$link = mysql_connect ('localhost','root','3141592653');
				mysql_query("SET NAMES utf8");
				mysql_select_db ('test_db', $link) or die ('Can\'t connect:' .mysql_error().'</br>Error #:'. mysql_errno());
				$this -> db_connect = $link;
		}
		
		public static function connect(){
			if (self::$obj === NULL){
				self::$obj = new Main();
			}
				return self::$obj->db_connect;
		}
		/*
		public function __destruct (){ 
				mysql_close ($this -> db_connect); 
				unset ($this -> db_connect);
				unset ($obj);
				echo "main destruct";
		}*/
	}
?>